using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BodySoundSimulator.Training
{
	class OpenCvAdapterNativeMethods
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		public delegate void ImagePushedDelegate(int width, int height, IntPtr imageDataPointer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		public delegate void StethLocationDataPushedDelegate(IntPtr locationDataPointer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		public delegate void CapturingFinishedDelegate();

		[DllImport("OpenCvAdapter.dll")]
		public static extern void StartProcessing();

		[DllImport("OpenCvAdapter.dll")]
		public static extern void StartCapturing([MarshalAs(UnmanagedType.FunctionPtr)]ImagePushedDelegate imagePushedDelegate, 
			[MarshalAs(UnmanagedType.FunctionPtr)]StethLocationDataPushedDelegate locationDataPushedDelegate);

		[DllImport("OpenCvAdapter.dll")]
		public static extern void StartCaptureAndRecord(StringBuilder fileName,
			[MarshalAs(UnmanagedType.FunctionPtr)]ImagePushedDelegate imagePushedDelegate,
			[MarshalAs(UnmanagedType.FunctionPtr)]StethLocationDataPushedDelegate locationDataPushedDelegate);

		[DllImport("OpenCvAdapter.dll")]
		public static extern void StartCapturingFromFile(StringBuilder fileName,
			[MarshalAs(UnmanagedType.FunctionPtr)]ImagePushedDelegate imagePushedDelegate,
			[MarshalAs(UnmanagedType.FunctionPtr)]StethLocationDataPushedDelegate locationDataPushedDelegate,
		   [MarshalAs(UnmanagedType.FunctionPtr)]CapturingFinishedDelegate capturingFinishedDelegate);

		[DllImport("OpenCvAdapter.dll")]
		public static extern void StopCapturing();

		[DllImport("OpenCvAdapter.dll")]
		public static extern void StartCallibration([MarshalAs(UnmanagedType.FunctionPtr)]ImagePushedDelegate imagePushedDelegate);

		[DllImport("OpenCvAdapter.dll")]
		public static extern void StopCallibration();

		[DllImport("OpenCvAdapter.dll")]
		public static extern void UpdateDataAndStopCallibration(IntPtr pArray, int size);
	}
}